package com.baboba.rummy.card;

import java.util.Arrays;
import java.util.LinkedList;

import com.baboba.rummy.shuffler.IShuffler;
import com.baboba.rummy.shuffler.RandomExchangeShuffler;

public class CardFactory {

	public static UserCard[] generateShownCards() {
		UserCard[] ShownCards = new UserCard[106];

		for (byte i = 0; i < 13; i++) {
			byte number = (byte) (i + (byte) 1);
			ShownCards[i] = new UserCard(number, Color.Red);
			ShownCards[i + 13] = new UserCard(number, Color.Red);
			ShownCards[i + 26] = new UserCard(number, Color.Blue);
			ShownCards[i + 39] = new UserCard(number, Color.Blue);
			ShownCards[i + 52] = new UserCard(number, Color.Black);
			ShownCards[i + 65] = new UserCard(number, Color.Black);
			ShownCards[i + 78] = new UserCard(number, Color.Orange);
			ShownCards[i + 91] = new UserCard(number, Color.Orange);
		}

		ShownCards[ShownCards.length - 2] = new UserCard();
		ShownCards[ShownCards.length - 1] = new UserCard();

		return ShownCards;
	}

	public static UserCard[] generateRandomShownCards() {
		UserCard[] ShownCards = generateShownCards();
		IShuffler<UserCard> shuffler = new RandomExchangeShuffler<UserCard>();
		shuffler.shuffle(ShownCards);
		return ShownCards;
	}

	public static LinkedList<UserCard> generateRandomShownCardsAsList() {
		LinkedList<UserCard> list = new LinkedList<UserCard>();
		list.addAll(Arrays.asList(generateRandomShownCards()));
		return list;
	}
}
